<?php !defined('IN_ONEZ') && exit('Access Denied');?>
<?php

/*
数据库说明
$db['site']='mysql://数据库账号:数据库密码@localhost:3306/数据库名?tablepre=表名前缀&charset=数据库编码';

示例
$db['site']='mysql://root:123456@localhost:3306/wordpress?tablepre=wp_&charset=utf8';
*/

if(GP('action')=='synlogin'){
  define('WP_USE_THEMES', true);
  require_once( dirname(ONEZ_ROOT) . '/wp-load.php' );
  wp();
}
#改成您自己的
$db['site']='mysql://root:123456@localhost:3306/wordpress?tablepre=wp_&charset=utf8';
function synlogin(){
  global $data;
  $uid=$data['uid'];
  
  wp_set_auth_cookie($uid);
  
  exit('<script>location.href="'.BACKURL.'";</script>');
}
function chklogin(){
  global $data,$usr,$pwd;
  
  require_once( dirname(ONEZ_ROOT).'/wp-includes/class-phpass.php');
  
  $T=D('site')->one('users','*',"user_login='$usr'");
  !$T && ero('用户名不存在');
  
  $wp_hasher = new PasswordHash(8, TRUE);
  $data = $wp_hasher->CheckPassword($pwd,$T['user_pass']);
  !$data && ero('密码不正确');
  
  $uid=$T['ID'];
  
  return $uid;
}